home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98c.txt
/
000076_icon-group-sender _Fri Nov 13 12:39:19 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
4KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) with SMTP id MAA27101
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Fri, 13 Nov 1998 12:39:19 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA07299; Fri, 13 Nov 1998 12:39:18 -0700
Date: Fri, 13 Nov 1998 12:09:03 -0500 (EST)
From: Mark Laster <mlaster@smart.net>
To: icon-group@optima.CS.Arizona.EDU
Subject: Coding multi-part patterns, as in SNOBOL
Message-Id: <Pine.LNX.3.95.981113120727.7576B-100000@smarty.smart.net>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Subject: Coding multi-part patterns, as in SNOBOL
Friday, 11/13/98
Hello,
After years of programming in SNOBOL, I've been learning ICON,
but some operations in ICON require me (because I don't know a
neater way) to write far more lines of code than would be
necessary in SNOBOL.
One of my programs in ICON processes e-mail messages. It does
more than the snippet shown here, but for purposes of
discussion, it removes the "e-mail quotation" marks from lines of
text. As you know, those marks in aggregate may be either:
(1) one or more angle brackets, starting at the left margin, or
(2) one or more spaces, starting at the left margin, FOLLOWED
IMMEDIATELY BY one or more angle brackets.
To remove these "e-mail quote" marks, I needed about 20 lines,
as shown below.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
procedure main ( )
...
# have gotten a line of text, called "rec" here, by now
repeat {
if /rec then {
rec := " "
break
}
else
if locnb := many('>', rec) then
rec := rec[locnb:0]
if dbg1 := (many(' ', rec)) then {
if dbg2 := (many('>', rec[dbg1])) then
rec := rec[dbg1+dbg2-1:0]
else # found starting blanks but no ">" immediately after
break
} # end of "if dbg1 := (many(' ' ..."
else # rec line does not start with blank or ">"
break
} # repeat for each workline
# write the record out
...
end
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
To perform the same operation in SNOBOL requires two lines (if
that many):
...
qupat = pos(0) (span(" ") | null) span(">") rem . rec
...
strip rec qupat :s(strip)
...
end
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I've read through the file PATTERNS.ICN, written in 1988, and I
know how to $include it, but I don't know how to use it. I'd
be glad to lose some run-time efficiency in order to gain some
coding-time efficiency.
Assuming that there is a way to code the quote-stripping
operation in ICON more efficiently than I have, optionally
using the PATTERNS.ICN file or superseding files, could you
show me how to do it in ICON, so I can see how to combine
multiple conditions in a match:
(1) starting at the left margin
(2) optionally encountering one or more blanks
(3) encountering one or more ">" directly afterward.
That would help me learn how to code a variety of complex
conditions.
Thank you very much.
Sincerely yours,
Mark Laster (301) 805-4462 mlaster@smart.net
15775 Easthaven Court
Bowie, MD 20716-2620